import { defineStore } from 'pinia';

const questionDataSurveyStore = defineStore('survey', {
  state: () => ({
    id: String,
    name: String,
    description: String,
    managedBy: 'admin',
    heatmap: [
      {
        name: '',
        value: 0,
      },
    ],
    questions: [
      {
        // 该题总回答人数
        total: 0,
        id: '',
        // 问题类型 0 是填空 单选是1 多选是2
        questionType: 0,
        // 题面
        stem: '',
        // 返回字符串 “bar”
        chartType: 'bar',

        // 每个选项
        choices: [
          {
            // 选项内容
            name: '',
            // 选的人数
            value: 0,
          },
        ],
      },
    ],

    answer: {
      total: 0,
      time: 0,
      questionTypes: [
        {
          name: '',
          value: 0,
        },
      ],
      questionUsers: [
        {
          name: '',
          value: 0,
        },
      ],
    },

    group: {
      questionnaire: 0,
      user: 0,
      time: 0,
      heatmap: [
        {
          name: '',
          value: 0,
        },
      ],
      sex: [
        {
          name: '',
          value: 0,
        },
      ],
      age: [
        {
          name: '',
          value: 0,
        },
      ],
      job: [
        {
          name: '',
          value: 0,
        },
      ],
    },
  }),
  persist: {
    enabled: true, // 开启存储
    // storage:sessionStorage/localStorage,还可以自定义存入对应的如下
  },
  // 定义getters，类似于computed，具有缓存g功能
  getters: {},
  // 定义actions，类似于methods，用来修改state，做一些业务逻辑
  actions: {},
});

export default questionDataSurveyStore;
